<?php

use \GatewayWorker\Lib\Gateway;
use \Module\DB;

require_once (__DIR__ . '/Config/Config.php');

require_once (__DIR__ . '/Lib/Server.php');
require_once (__DIR__ . '/Lib/G_CONST.php');
require_once (__DIR__ . '/Lib/DB_CONST.php');
require_once (__DIR__ . '/Lib/OPT_CONST.php');
require_once (__DIR__ . '/Lib/Account_CONST.php');
require_once (__DIR__ . '/Lib/Redis_CONST.php');
require_once (__DIR__ . '/Lib/Game.php');


class Base_Model
{
	
	/*
		实例化mmsql
	*/
	public function initMysql()
	{
		return \Module\DB\Mysql::instance("DB");
	}
	
	/*
		close mmsql
	*/
	public function closeMysql()
	{
		return \Module\DB\Mysql::close("DB");
	}


    /**
     * 写日志
     * @param $level
     * @param $content
     */
    public function logMessage($level,$content)
    {
        if ($level == "debug"){
            $this->writeDebugLog($content);
        }elseif($level == "error") {
            $this->writeErrorLog($content);
        }else {
            $this->writeLog($content);
        }
    }
    /**
     * 写日志
     * @param $content
     */
    public function writeLog($content)
    {
        $file = Config::Log_Dir. date("Y-m-d").'.log';
        file_put_contents($file, '['.date("H:i:s").'] '. $content . PHP_EOL,FILE_APPEND);
    }

    public function writeDebugLog($content){
        $file = Config::Log_Dir. 'debug-'.date("Y-m-d").'.log';
        file_put_contents($file, '['.date("H:i:s").'] '. $content . PHP_EOL,FILE_APPEND);
    }
    public function writeErrorLog($content){
        $file = Config::Log_Dir. 'error-'.date("Y-m-d").'.log';
        file_put_contents($file, '['.date("H:i:s").'] '. $content . PHP_EOL,FILE_APPEND);
    }
}

?>
